package concept.chapter7.backedcollections;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

public class ArrayCollectionsConverter
{
	public static void main(String[] args)
	{
		String[] array = new String[]{"ab","cd"};
		Collection<String> list = Arrays.asList(array);
		Collection<String> resultList = getMerged(list);
		System.out.println(resultList);
	}

	private static <E extends CharSequence> Collection<E> getMerged(Collection<? super String> list)
	{
		List<E> merged = new ArrayList<E>();
		
		for(Object o:list)
		{
			if(o instanceof CharSequence)
			{
				merged.add((E)o);
			}
		}
		
		return merged;
	}
	
}
